<?php
namespace app\api\controller\v1;
class Goods extends Base
{
    //列表
    public function lists(){
        if(is_post()){
            $d = request()->post();
            $map = [];
            if($d['cat_id']!=''){
                $map[] = ['cat_id','=',$d['parent_id']];
            }
            if($d['keyword']!=''){
                $map[] = ['title','like',"%{$d['keyword']}%"];
            }
            switch ($d['order']) {
                case '0':
                    # code...
                    break;

                default:
                    # code...
                    break;
            }
        	$rs = model('Goods')::where($map)
                                ->order('sort desc,id desc')
                                ->paginate($d['limit'],false,['page'=>$d['page']]);
            if($rs){
                $rs = $rs->toArray();
                return suc($rs['data'], $rs['total']);
            }else{
                return suc([],0);
            }
        }
    }
}
